#include <iostream>
#include<cmath>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include<queue>
using namespace std;
#define mod 1000000007
int main()
{
	long long n, sum = 1;
	cin >> n;
	int a[55];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	for (int i = 0; i < n; i++)
	{
		sum = sum * ((a[i] - i) % mod)%mod;
	}
	cout << sum << endl;
	return 0;
}